#ifndef GETHISTORYRESPONSE_H
#define GETHISTORYRESPONSE_H

#include "network/networkjsonlistresponse.h"


namespace Converse {
class AbstractMessage;
}

class GetHistoryResponse: public Network::JSONListResponse
{
    Q_OBJECT
public:
    class Item
    {
    public:
        Item(qint64 receiverId,
             qint64 created,
             const QString &extdata,
             qint64 senderId,
             qint64 mid,
             int type,
             qint64 chid,
             const QString &text);
    private:
        int m_receiverId;
        qint64 m_created;
        QString m_extdata;
        int m_senderId;
        qint64 m_mid;
        int m_mType;
        qint64 m_chid;
        QString m_text;

    public:
        inline qint64 receiverId() const {
            return m_receiverId;
        }

        inline qint64 created() const {
            return m_created;
        }

        inline const QString &extra() const {
            return m_extdata;
        }

        inline qint64 senderId() const {
            return m_senderId;
        }

        inline qint64 id() const {
            return m_mid;
        }

        inline int type() const {
            return m_mType;
        }

        inline qint64 chid() const {
            return m_chid;
        }

        inline const QString &text() const {
            return m_text;
        }
    };

public:
    typedef QList<Item *> Items;

public:
    explicit GetHistoryResponse(QObject *parent = 0);
    virtual ~GetHistoryResponse();

private:
    Items m_items;

private:
    // Parse list of history messages, skip invalid messages
    void parse(const QVariantList &list);

public:

    inline const Items &items() const {
        return m_items;
    }
};

#endif // GETHISTORYRESPONSE_H
